<template>
  <div>
    <div class="first-level-content base-table-box" v-if="!isShowSecond">
      <div class="table-select-group" v-show="!isAdvanced">
        <div class="left">
          <s-select
            :selectOption="year"
            v-model="params.strYear"
            style="width: 100px"
          />
          <s-select
            :selectOption="socialPublic.selectType"
            v-model="params.strPubType"
            style="width: 100px"
          />
          <a-input
            class="search-input"
            v-model="params.search"
            placeholder="请输入搜索内容"
          />
          <a-button style="margin-left: 16px" type="primary" @click="start"
            >查询</a-button
          >
          <a-button @click="reset" class="btn-reset">重置</a-button>
          <a-button @click="toggle" style="margin-left: 16px" type="primary"
            ><i
              class="suncnui suncnui-icon-shaixuanchaxun"
              style="margin-right: 6px; font-size: 12px"
            ></i
            >高级查询</a-button
          >
        </div>
        <div class="right">
          <a-button type="primary" @click="multipleEdit">采编</a-button>
        </div>
      </div>
      <div class="advanced-search-group" v-show="isAdvanced">
        <div class="advanced-name">
          <span>高级查询</span>
        </div>
        <a-form layout="inline" :label-col="labelCol" :wrapper-col="wrapperCol">
          <a-row>
            <a-col :span="8">
              <a-form-item label="信息年份">
                <s-select :selectOption="year" v-model="params.strYear" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="主题类型">
                <a-tree-select
                  :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                  :tree-data="treeData"
                  tree-default-expand-all
                  :treeIcon="true"
                  :showSearch="true"
                  v-model="topicTypeVal"
                >
                </a-tree-select>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="反映人">
                <s-select
                  :selectOption="reactionOption"
                  v-model="params.reaction"
                />
              </a-form-item>
            </a-col>
          </a-row>
          <a-row style="margin-top: 10px">
            <a-col :span="8">
              <a-form-item label="信息状态">
                <a-select default-value="">
                  <a-select-option value="">=紧急程度=</a-select-option>
                  <a-select-option value="0"> 一般紧急 </a-select-option>
                  <a-select-option value="1"> 非常紧急</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="信息状态">
                <a-select default-value="">
                  <a-select-option value="">全部</a-select-option>
                  <a-select-option value="0"> 信息标题 </a-select-option>
                  <a-select-option value="1"> 信息来源</a-select-option>
                  <a-select-option value="2"> 信息内容</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="关键字">
                <a-input placeholder="请输入搜索内容" />
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
        <div class="search-btn">
          <a-button style="margin-left: 16px" type="primary" @click="start"
            >查询</a-button
          >
          <a-button @click="reset" class="btn-reset">重置</a-button>
        </div>
        <div class="search-switch" @click="toggle">
          <i class="suncnui suncnui-icon-prev-1"></i>
        </div>
      </div>
      <a-table
        :row-selection="{
          selectedRowKeys: selectedRowKeys,
          onChange: onSelectChange
        }"
        :pagination="pagination"
        :columns="columns"
        :data-source="tableData"
        :loading="loading"
        :scroll="{ y: '100%' }"
      >
        <div slot="action">
          <div class="tools">
            <span @click="editClick">采编</span>
          </div>
        </div>
      </a-table>
    </div>
    <div class="second-level-content base-table-box" v-if="isShowSecond">
      <div class="table-select-group">
        <div class="right">
          <a-button type="primary">确定</a-button>
          <a-button type="primary" @click="back">返回</a-button>
        </div>
      </div>
      <a-checkbox-group @change="onCheckboxChange">
        <a-table
          :columns="secondColumns"
          :data-source="tableData"
          :loading="loading"
          :scroll="{ y: '100%' }"
        >
          <div slot="selectAction" slot-scope="text, record">
            <div class="tools">
              <a-checkbox :value="record.key"> </a-checkbox>
            </div>
          </div>
          <template slot-scope="text, record, index" slot="listIndex">
            <span>{{ index + 1 }}</span>
          </template>
        </a-table>
      </a-checkbox-group>
    </div>
  </div>
</template>
<script>
import paging from 'mixins/paging'
import deleteItem from 'mixins/delete-table-item.js'
import { socialPublic } from 'assets/js/select-option-list'
const columns = [
  {
    title: '信息标题',
    dataIndex: 'title'
  },
  {
    title: '信息来源',
    dataIndex: 'source'
  },
  {
    title: '反映人类型',
    dataIndex: 'type'
  },
  {
    title: '主题类型',
    dataIndex: 'topicType'
  },
  {
    title: '提交时间',
    dataIndex: 'time'
  },
  {
    title: '刊物类型',
    dataIndex: 'publicationType'
  },
  {
    title: '操作',
    scopedSlots: { customRender: 'action' }
  }
]

export default {
  data() {
    return {
      isShowSecond: false,
      selectedRowKeys: [],
      topicTypeVal: '',
      treeData: [
        {
          title: '=主题类型=',
          value: '',
          key: '1'
        },
        {
          title: '文化建设',
          value: '文化建设',
          key: '2',
          children: [
            {
              value: '街道文化建设',
              key: '2-1',
              title: '街道文化建设'
            }
          ]
        },
        {
          title: '经济建设',
          value: '经济建设',
          key: '3'
        },
        {
          title: '政协建设',
          value: '政协建设',
          key: '4'
        }
      ],
      isAdvanced: false,
      columns,
      secondColumns: [
        {
          title: '序号',
          scopedSlots: { customRender: 'listIndex' }
        },
        {
          title: '信息标题',
          dataIndex: 'title'
        },
        {
          title: '信息来源',
          dataIndex: 'source'
        },
        {
          title: '反映人类型',
          dataIndex: 'type'
        },
        {
          title: '主题类型',
          dataIndex: 'topicType'
        },
        {
          title: '操作',
          scopedSlots: { customRender: 'selectAction' }
        }
      ],
      socialPublic,
      params: {
        strYear: '2021',
        strPubType: 'all',
        strPubNode: 'all',
        search: '',
        reaction: ''
      },
      year: [
        { key: '2021', label: '2021' },
        { key: '2020', label: '2020' }
      ],
      reactionOption: [
        { key: '', label: '=反映人类型=' },
        { key: '1', label: '团体' },
        { key: '0', label: '党派' },
        { key: '1', label: '团体' },
        { key: '3', label: '专委会' },
        { key: '4', label: '届别' },
        { key: '5', label: '当前届次委员' },
        { key: '6', label: '承办单位' },
        { key: '7', label: '承办系统' }
      ],
      labelCol: { span: 6 },
      wrapperCol: { span: 18 }
    }
  },
  mixins: [paging, deleteItem],
  methods: {
    onCheckboxChange(checkedValues) {
      console.log(checkedValues)
    },
    //多条采集
    multipleEdit() {
      this.isShowSecond = true
    },
    back() {
      this.isShowSecond = false
    },
    editClick() {
      //采编
      this.$router.push(
        '/console/socialPublic/publication/infoCollection/infoCollectionEdit'
      )
    },
    toggle() {
      this.isAdvanced = !this.isAdvanced
    },
    start() {
      console.log(this.form)
    },
    reset() {
      this.form = {}
    },
    add() {},
    deleteList(ids) {
      this.deleteItemMixins(() => {}, ids)
    },
    getTableData() {
      for (let i = 0; i < this.pagination.pageSize; i++) {
        this.tableData.push({
          key: i,
          title: `Edward King ${i}`,
          source: '张三',
          time: `20210303`,
          type: '政协委员',
          topicType: '经济建设',
          publicationType: '社情民意'
        })
      }
      this.pagination.total = 200
    }
  }
}
</script>
<style lang="less" scoped>
.tools span:last-child {
  margin: 0 0 0 15px;
}
.tools span {
  color: #1c8de8;
  cursor: pointer;
  font-size: 16px;
}
.end {
  color: green;
}
.start {
  color: red;
}
.advanced-name {
  line-height: 34px;
  margin-bottom: 5px;
  font-size: 16px;
  color: #000000;
  font-weight: bold;
  span {
    height: 20px;
    line-height: 20px;
    /* border-left: 5px solid #0b78e7; */
    padding: 0px 10px;
    display: inline-block;
    vertical-align: middle;
    margin-top: -3px;
    margin-right: 5px;
  }
}
.advanced-search-group {
  padding: 15px 10px 5px 15px;
}
.search-btn {
  text-align: center;
  margin-top: 10px;
}
.advanced-search-group {
  padding-bottom: 40px;
  position: relative;
  background: #fff;
}
.search-switch {
  width: 36px;
  height: 36px;
  position: absolute;
  bottom: -10px;
  left: 50%;
  text-align: center;
  cursor: pointer;
  background: #ffffff;
  border-radius: 50%;
  margin-left: -18px;
  i {
    color: #4297ee;
    font-size: 20px;
    margin-top: 10px;
    display: inline-block;
    animation: arrow 0.7s linear infinite normal;
  }
}
@keyframes arrow {
  from {
    margin-top: 10px;
  }
  to {
    margin-top: 5px;
    opacity: 0;
  }
}
.ant-form-inline .ant-form-item {
  width: 100%;
}
</style>